{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "private_outputs": true,
      "authorship_tag": "ABX9TyPRrOGxWtu+4BRem/IMinSc",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/mesop-dev/mesop/blob/main/notebooks/mesop_colab_getting_started.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Mesop\n",
        "\n",
        "https://mesop-dev.github.io/mesop/\n",
        "\n",
        "Mesop is a Python-based UI framework that allows you to rapidly build web apps like demos and internal apps"
      ],
      "metadata": {
        "id": "8r6nOL0xPfyU"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Getting Started"
      ],
      "metadata": {
        "id": "ZCtrRuMdPpJG"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install mesop"
      ],
      "metadata": {
        "id": "buRfwUlqPons"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "import mesop as me\n",
        "import mesop.labs as mel\n",
        "\n",
        "me.colab_run()"
      ],
      "metadata": {
        "id": "hnyh1SX_P1XV"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Mesop Examples"
      ],
      "metadata": {
        "id": "jNb8UJbpPwNj"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Hello World"
      ],
      "metadata": {
        "id": "EKtdsEFKP_te"
      }
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "4NGHpjd5PZld"
      },
      "outputs": [],
      "source": [
        "@me.page(path=\"/hello_world\")\n",
        "def hello_world():\n",
        "  me.text(\"Hello World!\")"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "me.colab_show(path=\"/hello_world\", height=100)"
      ],
      "metadata": {
        "id": "AqBWw22vP4vI"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "## Simple Chat"
      ],
      "metadata": {
        "id": "_l1xYfyHQBS-"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "@me.page(path=\"/chat\")\n",
        "def chat():\n",
        "  mel.chat(transform)\n",
        "\n",
        "def transform(prompt: str, history: list[mel.ChatMessage]) -> str:\n",
        "  return \"Hello \" + prompt"
      ],
      "metadata": {
        "id": "dhKgb-YfQDHJ"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "me.colab_show(path=\"/chat\")"
      ],
      "metadata": {
        "id": "JhgA_hFbQFCl"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}
